<template>
  <div class="check_amount">
    <el-form class="form" :model="form" :rules="rules" ref="form" label-width="20%">
      <el-form-item class="form_item" label="羽数校验">
        <el-radio-group v-model="form.ischeck" prop="ischeck">
            <el-radio :label="1">通过</el-radio>
            <el-radio :label="0">不通过</el-radio>
        </el-radio-group>
      </el-form-item>
      <el-form-item class="form_item" label="校验说明">
        <el-input v-model="form.checkmsg" placeholder="请输入" type="textarea" :rows="3" clearable></el-input>
      </el-form-item>
    </el-form>
    <div class="footer">
      <el-button class="cancel_button" @click="cancel">{{$t("common.CANCEL")}}</el-button>
      <el-button class="confirm_button" @click="addSubmit()">{{$t("common.CONFIRM2")}}</el-button>
    </div>
  </div>
</template>

<script>
import i18n from "@/lang";
import receiptService from "@/service/receiptService";

export default {
  name: "addReceiptTask",
  props: ['detailData'],
  data() {
    return {
      form: {},
      rules: {
        ischeck: [{ required: true, message: '请选择' }]
      },
    };
  },
  created() {
      this.form = JSON.parse(this.detailData)
  },
  methods: {
    addSubmit() {
        this.$refs.form.validate((valid) => {
            if (valid) {
                let params = {
                  id: this.form.id,
                  ischeck: this.form.ischeck,
                  checkmsg: this.form.checkmsg
                }
                receiptService.checkAmount(params).then(res => {
                    if (res && res.data.result === 0) {
                        this.$message.success('操作成功!');
                        this.$emit('closeVisible')
                    }
                })
            }
        })
    },
    cancel() {
        this.$emit('closeVisible', 'cancel')
    },
  },
};
</script>

<style>
.check_amount .footer {
  display: flex;
  justify-content: flex-end;
}
.check_amount .form .form_item{
    margin-bottom: 30px;
}
</style>